﻿<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${path }/resource/plugin/hui/lib/html5.js"></script>
<script type="text/javascript" src="${path }/resource/plugin/hui/lib/respond.min.js"></script>
<script type="text/javascript" src="${path }/resource/plugin/hui/lib/PIE_IE678.js"></script>
<![endif]-->

<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/EXBase.js"></script>

<link rel="stylesheet"
	href="${path }/resource/plugin/kindeditor/themes/default/default.css" />
<link rel="stylesheet"
	href="${path }/resource/plugin/kindeditor/plugins/code/prettify.css" />
<script src="${path }/resource/plugin/kindeditor/kindeditor.js"></script>
<script src="${path }/resource/plugin/kindeditor/lang/zh_CN.js"></script>
<script
	src="${path }/resource/plugin/kindeditor/plugins/code/prettify.js"></script>
	
	
	<script type="text/javascript" src="${path }/resource/plugin/hui/lib/My97DatePicker/WdatePicker.js"></script> 


<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
</head>
<body>
	<div class="pd-20">
		<form class="form form-horizontal" method="post"
			action="admin/article/addOrModify" id="dataform"
			onsubmit="javascripr:return false;">
			<c:if test="${obj ne null }">
				<input type="hidden" name="id" value="${obj.id }">
			</c:if>
			<div class="row cl">

				<label class="form-label col-1">文章来源</label>
				<div class="formControls col-3">
					<select class="select select-box" size="1" name="source">
						<c:forEach items="${sourceList }" var="item">
							<option
								<c:if test="${obj ne null && obj.source eq item }"> selected="selected" </c:if>
								value='${item }'>${item }</option>
						</c:forEach>
					</select>
				</div>
				<div class="col-2">
					<span class="Validform_checktip"></span>
				</div>


				<label class="form-label col-1">发布类型</label>
				<div class="formControls col-3">
					<select class="select select-box" size="1" name="cateId"
						id="cateId">

					</select>
				</div>
				<div class="col-2">
					<span class="Validform_checktip"></span>
				</div>


			</div>

			<div class="row cl">
				<label class="form-label col-1">作者</label>
				<div class="formControls col-3">
					<input type="text" dataType="*" ignore="ignore" class="input-text" name="author"
						value="${obj.author }">
				</div>
				<div class="col-2">
					<span class="Validform_checktip"></span>
				</div>

				<label class="form-label col-1">标题</label>
				<div class="formControls col-3">
					<input type="text" dataType="*"  ignore="ignore"  class="input-text" name="name"
						value="${obj.name }">
				</div>
				<div class="col-2">
					<span class="Validform_checktip"></span>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-1">是否立刻发布</label>
				<div class="formControls col-3">
					<c:if test="${obj ne null }">
						<label><input type="radio" name="isShow" value="1"
							<c:if test="${obj ne null && obj.isShow eq 1 }"> checked="checked" </c:if>>是</label>
						<label><input type="radio" name="isShow"
							<c:if test="${obj ne null && obj.isShow eq 2 }"> checked="checked" </c:if>
							value="2">否</label>
					</c:if>
					<c:if test="${obj eq null }">
						<label><input type="radio" name="isShow" value="1"
							checked="checked">是</label>
						<label><input type="radio" name="isShow" value="2">否</label>
					</c:if>
				</div>
				<div class="col-2">
					<span class="Validform_checktip"></span>
				</div>

				<label class="form-label col-1">是否可以评论</label>
				<div class="formControls col-3">
					<c:if test="${obj ne null }">
						<label><input type="radio" name="iscommont" value="1"
							<c:if test="${obj ne null && obj.iscommont eq 1 }"> checked="checked" </c:if>>是</label>
						<label><input type="radio" name="iscommont"
							<c:if test="${obj ne null && obj.iscommont eq 2 }"> checked="checked" </c:if>
							value="0">否</label>
					</c:if>
					<c:if test="${obj eq null }">
						<label><input type="radio" name="iscommont" value="1"
							checked="checked">是</label>
						<label><input type="radio" name="iscommont" value="2">否</label>
					</c:if>
				</div>
				<div class="row cl">
					<label class="form-label col-1">文章摘要</label>
					<div class="formControls col-5">
						<input value="${obj.description}" datatype="*1-550"   ignore="ignore" 
							style="width: 50%;" name="description" class="input-text"
							type="text" id="zy-input"><input
							class='btn radius btn-primary' type="button" value="自动抓取"
							onclick="autoZy()"> <input class='btn radius btn-primary'
							type="button" value="清空摘要" onclick="cleanZy()">
					</div>
					<label class="form-label col-1">文章时间</label>
					<div class="formControls col-3">
						<input class="input-text" name="votime" type="text" value="<fmt:formatDate value="${obj.time }" pattern="yyyy-MM-dd"></fmt:formatDate>" onClick="WdatePicker()"/>
					</div>
					<div class="col-2">
						<span class="Validform_checktip"></span>
					</div>
					
					
				</div>

				<div class="row cl">
					<label class="form-label col-1">文章内容</label>
					<div class="formControls col-9">
						<textarea name="content" id="artcontent">
						${obj.content}
						</textarea>
					</div>
					<div class="col-2">
						<span class="Validform_checktip"></span>
					</div>
				</div>

				<div class="row cl">
					<label class="form-label col-1">展示图片</label>

					<div class="formControls col-9">
						<span class="btn-upload form-group"> <input
							onclick="EXCommon.chooesFile()"
							class="input-text upload-url radius" type="text"
							id="showFileName" readonly> <a
							onclick="EXCommon.chooesFile()" class="btn btn-primary radius"><i
								class="fa fa-cloud-upload"></i> 浏览文件</a>
						</span> <input type="button" class='btn btn-primary radius'
							onclick="EXCommon.upFile()" value="上传"> <a
							id="selectInServices" class="btn btn-primary radius"><i
							class="fa fa-cloud"></i> 远程图库</a>
					</div>
				</div>

				<div class="row cl">
					<div class="col-1"></div>
					<div class="col-md-offset-1 formControls col-9">
						<c:if test="${obj ne null }">
							<input type="hidden" value="${obj.showImg1}" name="showImg1" id="hiddenImg" />
							<img width="150" id='img_1' src="${obj.showImg1	 }" />
						</c:if>
						<c:if test="${obj eq null }">
							<input type="hidden" name="showImg1" id="hiddenImg" />
							<img width="150" id='img_1' style="display: none" />
						</c:if>
					</div>
				</div>

				<div class="row cl ">
					<div class="col-10 col-offset-2">
						<a href="javascript:void(0)" onclick="EXForm.submit()"
							class="btn btn-success radius" id="save-btn">保存</a>
					</div>
				</div>
		</form>

		<form class="form form-horizontal" method="post"
			style="display: none;" enctype="multipart/form-data"
			target="blankFrame"
			action="${path }/resource/plugin/kindeditor/upload_json.jsp?dir=image&flag=img_1&hiddenImg=hiddenImg">
			<input id="fileText" type="file" multiple name="file-1"
				onchange="EXCommon.selectFile('#showFileName')" /> <input
				type="submit" id="submitBtn"
				onclick="EXCommon.upolad('img_1','file_1')" />
		</form>
		<iframe src="" name="blankFrame" id="blankFrame"
			style="height: 100px; width: 100px; display: none;"> </iframe>


	</div>
	<script type="text/javascript">
		var editor1 = null;
		$(function() {
			EXUI.createEdit("content", '100%', '400px', 'editor1');
			initFunctionList();
			//表单提交前同步编辑器数据
			EXForm.initForm({beforeSubnit:function(){
				editor1.sync();
			}});
			EXUI.openServiceImgSpace(function(url) {
				$("#img_1").attr("src", url).show();
				$("#hiddenImg").val(url);
			}, "#selectInServices");
		});

		/**
		 * 初始化类型列表
		 */
		function initFunctionList() {
			$.AjaxProxy({
				a : false,
				c : false
			}).invoke("admin/articleCate/all", function(loj) {
				$("#cateId").createSelectTree(loj.attr("result").dataList, {
					append : true,
					<c:if test="${obj ne null }">
					defaultValue:${obj.cateId}
					</c:if>
				});
			});

		}
		function autoZy() {
			var text = editor1.text();
			$("#zy-input").val(text.substring(0, 100));
		}
		function cleanZy() {
			$("#zy-input").val("");
		}
	</script>
</body>
</html>